/*
 * @Descripttion: 
 * @version: 
 * @Author: yuanliutech
 * @Date: 2022-11-30 09:18:03
 * @LastEditors: yuanliutech@lwj
 * @LastEditTime: 2025-03-11 11:32:53
 */

const menu = {
    state: {
        cursor: 'grab',
        orgarr: JSON.parse(window.sessionStorage.getItem("orgarr")) || {}, //单位详情
        infoSent: window.sessionStorage.getItem("infoSent"), //监听告警推送数据+1
        msgList: window.sessionStorage.getItem("msgList") || {}, //推送告警信息
        sum: window.sessionStorage.getItem("sum") || true, //监听是否处理了告警
        end: window.sessionStorage.getItem("end") || true, //监听是否完结了
        buildingsSum: window.sessionStorage.getItem("buildingsSum") || 0, //建筑物数量

        /* MTQQ服务 */
        mp: window.sessionStorage.getItem("mp") || '', //客户端密码
        mu: window.sessionStorage.getItem("mu") || '', //客户端名称
        clientId: window.sessionStorage.getItem("clientId") || '', //客户端id

        /*建筑物详情*/
        buildingsArr: JSON.parse(window.sessionStorage.getItem("buildingsArr")) || {}, //建筑物详情
        floorId: window.sessionStorage.getItem("floorId") || '', //楼层id
        floorFlag: window.sessionStorage.getItem("floorFlag") || true, //监听楼层点击事件
        spacesArr: JSON.parse(window.sessionStorage.getItem("spacesArr")) || {}, //安装点信息
        spacesFlag: window.sessionStorage.getItem("spacesFlag") || true, //监听安装点点击事件

        // 如约单位信息
        orgInfo: JSON.parse(window.sessionStorage.getItem("orgInfo")) || {}, //单位详情
    },

    mutations: {
        saveCursor(state, val) {
            state.cursor = val;
        },
        // 存储单位详情
        saveorgarr(state, orgarr) {
            state.orgarr = orgarr;
            window.sessionStorage.setItem("orgarr", JSON.stringify(orgarr));
        },
        saveOrgInfo(state, orgInfo) {
            state.orgInfo = orgInfo;
            window.sessionStorage.setItem("orgInfo", JSON.stringify(orgInfo));
        },
        // mqtt的username
        saveMu(state, mu) {
            state.mu = mu
            window.sessionStorage.setItem('mu', mu)
        },
        // mqtt的password
        saveMp(state, mp) {
            state.mp = mp
            window.sessionStorage.setItem('mp', mp)
        },
        // mqtt的id
        saveId(state, clientId) {
            state.clientId = clientId
            window.sessionStorage.setItem('clientId', clientId)
        },
        // 实时告警触发告警相关更新
        saveInfoSent(state, infoSent) {
            state.infoSent = infoSent
            window.sessionStorage.setItem("infoSent", infoSent)
        },
        // 推送告警的信息
        saveMsgList(state, msgList) {
            state.msgList = msgList
            window.sessionStorage.setItem("msgList", msgList)
        },
        //监听是否处理了告警   -1
        saveSum(state, sum) {
            state.sum = sum
            window.sessionStorage.setItem("sum", sum)
        },
        //监听是否完结了
        saveEnd(state, end) {
            state.end = end
            window.sessionStorage.setItem("end", end)
        },
        // 建筑物数量
        savebuildingsSum(state, buildingsSum) {
            state.buildingsSum = buildingsSum
            window.sessionStorage.setItem("buildingsSum", buildingsSum)
        },
        // 存储建筑物详情
        savebuildingsArr(state, buildingsArr) {
            state.buildingsArr = buildingsArr;
            window.sessionStorage.setItem("buildingsArr", JSON.stringify(buildingsArr));
        },
        // 存储楼层id
        savefloorId(state, floorId) {
            state.floorId = floorId
            window.sessionStorage.setItem('floorId', floorId)
        },
        //监听楼层
        savefloorFlag(state, floorFlag) {
            state.floorFlag = floorFlag
            window.sessionStorage.setItem("floorFlag", floorFlag)
        },
        // 存储安装点信息
        savespacesArr(state, spacesArr) {
            state.spacesArr = spacesArr
            window.sessionStorage.setItem('spacesArr', JSON.stringify(spacesArr))
        },
        //监听安装点
        savespacesFlag(state, spacesFlag) {
            state.spacesFlag = spacesFlag
            window.sessionStorage.setItem("spacesFlag", spacesFlag)
        },
    },

    actions: {

    },
};

export default menu;